<template>
	<div>

		<el-dialog title="发货" :visible.sync="sendgoodsModel" width="50%" center top="10vh" :close-on-click-modal='false'>
			<el-form label-width="7em" v-model="sendForm">
				<el-form-item label="物流公司">
					<el-select v-model="sendForm.transName" filterable placeholder="物流公司">
						<el-option v-for="n in expressList" :label="n.name" :value="n.value"></el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="物流公司电话">
					<el-input placeholder="请输入物流公司电话" v-model="sendForm.transMobile" />
				</el-form-item>

				<el-form-item label="单号">
					<el-input placeholder="请输入单号" v-model="sendForm.transNo" />
				</el-form-item>

			</el-form>

			<span slot="footer" class="dialog-footer">
              <el-button @click="sendgoodsModel=false">取消</el-button>
              <el-button type="primary" @click="send()">确定</el-button>
            </span>
		</el-dialog>

		<el-dialog :visible.sync="viewBig" width="400px">
			<img :src="bigIcon" style="width:400px;height:400px;margin:-55px -20px -40px">
		</el-dialog>

		<div v-if="pageId === '0'">

			<el-form label-position="left" inline class="demo-table-expand">
				<el-form-item label="订单状态" style="margin:0">
					<el-select v-model="form.orderstatus" placeholder="订单状态">
						<el-option label="全部" value=""></el-option>
						<el-option label="等待支付" value="ORDER_WAIT_PAY"></el-option>
						<el-option label="订单关闭" value="ORDER_CANCEL_PAY"></el-option>
						<el-option label="等待发货" value="ORDER_WAIT_SENDGOODS"></el-option>
						<el-option label="等待收货" value="ORDER_WAIT_RECVGOODS"></el-option>
						<el-option label="订单完成" value="ORDER_END_GOODS"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="getOrderList()" style="    margin-right: 10px;margin-bottom: 22px;">搜索</el-button>
				</el-form-item>
			</el-form>

			<el-table :data="orderTableData" style="width: 100%" :expand-change="expandOnchange">

				<el-table-column prop="name" label="状态" sortable>
					<template scope="scope">
						<span>{{ handleOrderStatus(scope.row.orderStatus)}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="name" label="退款" sortable>
					<template scope="scope">
						<span>{{ handleOrderRefundStatus(scope.row.refundStatus)}}</span>
					</template>
				</el-table-column>

				<el-table-column sortable prop="date" label="订单号">
					<template scope="scope">
						<span>{{ scope.row.orderId}}</span>
					</template>
				</el-table-column>

				<el-table-column sortable prop="name" label="订单金额">
					<template scope="scope">
						<span> ￥{{ scope.row.payTotal}}</span>
					</template>
				</el-table-column>

				<el-table-column sortable prop="name" label="联系人">
					<template scope="scope">
						<span>{{ scope.row.contactName}}</span>
					</template>
				</el-table-column>
				<el-table-column sortable prop="name" label="联系号码">
					<template scope="scope">
						<span>{{ scope.row.contactPhone}}</span>
					</template>
				</el-table-column>

				<el-table-column sortable prop="name" label="地区">
					<template scope="scope">
						<span>{{ scope.row.provinceName}}{{ scope.row.cityName}}</span>
					</template>
				</el-table-column>

				<el-table-column sortable prop="name" label="下单时间">
					<template scope="scope">
						<span>{{ scope.row.createTime}}</span>
					</template>
				</el-table-column>
				<el-table-column label="操作" width="500" align="center" >
					<template scope="scope">

						<el-button :style="scope.row.orderStatus !== 'ORDER_WAIT_SENDGOODS' ?'visibility: hidden;':''" type="primary" size="small" @click="doSendgoods(scope.row)" v-if="$store.getters.getRoleTpye === 'admin' ||handelUpdateRole(22)">发货</el-button>
						<!-- <el-button  :style="scope.row.refundStatus !== 'APPLY_REFUND' ?'visibility: hidden;':''" type="danger" size="small" @click="doRefund(scope.row)"  >处理退款</el-button> -->
						<el-button type="info" plain="" size="small" @click="goDetil(scope.row.orderId)" v-if="$store.getters.getRoleTpye === 'admin' ||handelUpdateRole(20)">详情</el-button>
						<!-- <el-button  :style="scope.row.refundOrder ?'':'visibility: hidden;'" type="danger" size="small" @click="changeRefundInfoModel(scope.row)"  >退款信息</el-button> -->

					</template>
				</el-table-column>
			</el-table>
			<div class="block" align="right">
				<br>
				<el-pagination @current-change="handleCurrentChange" layout=" prev, pager, next" :total="count">
				</el-pagination>
			</div>

			<el-dialog title="退款信息" :visible.sync="refundInfoModel" width="50%" center top="10vh" :close-on-click-modal='false'>
				<el-form label-width="6em" v-model="sendForm">

					<div>
						<el-form-item label="退款状态">
							<span>{{handleOrderRefundStatus(refundOrder.refundStatus)}}</span>
						</el-form-item>
					</div>

					<div>
						<el-form-item label="退款金额">
							<span>{{refundOrder.refundAmount}}</span>
						</el-form-item>
					</div>

					<div>

						<el-form-item label="退款原因">
							<span>{{refundOrder.refundReason}}</span>
						</el-form-item>
					</div>

					<div>
						<el-form-item label="退款时间">
							<span>{{refundOrder.createTime}}</span>
						</el-form-item>

					</div>
				</el-form>

			</el-dialog>

		</div>

		<div v-if="pageId === '1'">

			<el-button type="primary" size="small" @click="$route.query.orderId?$router.go(-1): pageId = '0'" plain=""><i class="el-icon-arrow-left"></i> 返回</el-button>

			<el-form label-position="left" inline class="demo-table-expand">

				<h3>商品信息</h3>

				<el-row>
					<el-col :span="5" v-for="(o, index) in orderDatil.detailList" :key="o" :offset="index > 0 ? 2 : 0" style="float: left;margin-left: 10px;margin-bottom:10px">
						<el-card :body-style="{ padding: '0px' }">
							<img :src="o.goodsIcon" style="    width: 100%;" class="image">
							<div style="padding: 14px;">
								<div>
									<el-form-item label="商品名称" style="margin:0;height: 100px;">
										<span>{{o.goodsName}}</span>
									</el-form-item>
								</div>

								<div>
									<el-form-item label="购买数量" style="margin:0">
										<span>{{o.num}}</span>
									</el-form-item>
								</div>
								<div>
									<el-form-item label="金额" style="margin:0">
										<span>￥{{o.price}}</span>
									</el-form-item>
								</div>

								<!-- <div class="bottom clearfix">
          <time class="time">{{ currentDate }}</time>
        </div> -->
							</div>
						</el-card>
					</el-col>
				</el-row>

				<h3>订单详情</h3>

				<el-row :gutter="24">
					<el-col :span="12">
						<div>
							<el-form-item label="订单号">
								<span>{{orderDatil.orderId}}</span>
							</el-form-item>
						</div>
						<div>
							<el-form-item label="订单状态">
								<span>{{ handleOrderStatus(orderDatil.orderStatus)}}</span>
							</el-form-item>
						</div>

						<div>
							<el-form-item label="支付金额">
								<span>￥{{ orderDatil.payTotal}}</span>
							</el-form-item>
						</div>

						<div>
							<el-form-item label="下单时间">
								<span>{{ orderDatil.createTime}}</span>
							</el-form-item>
						</div>
						<h3>联系信息</h3>
						<el-form-item>
							<div>{{orderDatil.contactName}} {{orderDatil.contactPhone}} </div>
							<div> {{orderDatil.provinceName}} {{orderDatil.cityName}} {{orderDatil.countryName}} {{orderDatil.address}} </div>
						</el-form-item>

						<div v-if="isrefund">
							<h3>退款信息</h3>

							<el-form label-width="6em">

								<div>
									<el-form-item label="退款状态">
										<span>{{handleOrderRefundStatus(orderDatil.refundStatus)}}
              <el-button  :style="orderDatil.refundStatus !== 'APPLY_REFUND' || orderDatil.orderStatus === 'ORDER_END_GOODS' ?'visibility: hidden;':''" v-if="$store.getters.getRoleTpye === 'admin' ||handelUpdateRole(21)" type="danger" plain size="small" @click="doRefund()"  >处理退款</el-button>
            </span>
									</el-form-item>
								</div>

								<div>
									<el-form-item label="退款金额">
										<span v-if="orderDatil.refundOrder">{{orderDatil.refundOrder.refundAmount}}</span>
									</el-form-item>
								</div>

								<div>

									<el-form-item label="退款原因">
										<span v-if="orderDatil.refundOrder">{{orderDatil.refundOrder.refundReason}}</span>
									</el-form-item>
								</div>

								<div>

									<el-form-item label="退款图片" v-if="orderDatil.refundOrder">
										<img v-for="n in orderDatil.refundOrder.refundImg.split(',')" :src="n" v-show="orderDatil.refundOrder.refundImg!=''" style="width:80px;height:80px;margin:15px" @click="viewBigIcon(n)" />
									</el-form-item>
								</div>

								<div>
									<el-form-item label="退款时间" v-if="orderDatil.refundOrder">
										<span>{{orderDatil.refundOrder.createTime}}</span>
									</el-form-item>

								</div>
							</el-form>
						</div>
					</el-col>

					<el-col :span="12">
						<div v-if="orderDatil.orderStatus !== 'ORDER_CANCEL_PAY' && orderDatil.orderStatus !== 'ORDER_WAIT_SENDGOODS' && orderDatil.orderStatus !== 'ORDER_WAIT_PAY'">
							<h3>物流信息

              <el-button v-if="orderDatil.orderStatus === 'ORDER_WAIT_RECVGOODS'"   type="primary" plain size="small" @click="doChangeShip({orderId:orderDatil.orderId})"  >更改物流</el-button>
                           
                         </h3>

							<el-form label-width="150px">
								<div style="display: flex;align-items: center;padding:10px 0 ">
									<div style="width:90px">
										物流公司:
									</div>
									<div>{{ handleShipCode(shipList.shipper_code) }}</div>
								</div>
								<div style="display: flex;align-items: center;padding:10px 0">

									<div style="width:90px">
										单号:
									</div>
									<div>{{shipList.logistic_code}}</div>
								</div>
								<div style="display: flex;align-items: center;padding:10px 0">

									<div style="width:90px">
										物流电话:
									</div>
									<div>{{shipList.mobile}}</div>
								</div>

								<div style="height:500px;overflow-y: scroll;">
									<div v-for="n in shipList.traces" style="    padding: 10px 0 10px 20px;">
										<div style="padding:5px 0">
											{{n.AcceptTime}}
										</div>
										<div>
											{{n.AcceptStation}}
										</div>
									</div>
								</div>
							</el-form>
						</div>
					</el-col>
				</el-row>
			</el-form>
		</div>
		<!-- 详情 -->

		<el-dialog title="处理退款" :visible.sync="refundModel" width="50%" center top="10vh" :close-on-click-modal='false'>
			<el-form label-width="6em" v-model="refundOrderForm">

				<el-form-item label="退款金额">
					<span>{{refundOrderForm.refundOrder.refundAmount}}</span>
				</el-form-item>

				<el-form-item label="退款原因">
					<span>{{refundOrderForm.refundOrder.refundReason}}</span>
				</el-form-item>
				<el-form-item label="申请图片">
					<span v-for="n in imageList">
    <img :src="n" style="width:80px;height:80px;margin:15px" @click="viewBigIcon(n)" />
  </span>
				</el-form-item>
				<el-form-item label="申请时间">
					<span>{{refundOrderForm.refundOrder.createTime}}</span>
				</el-form-item>
				<el-form-item label="是否同意">
					<el-radio-group v-model="refundOrderForm.isRefund">
						<el-radio :label="true">同意退款</el-radio>
						<el-radio :label="false">拒绝退款</el-radio>
					</el-radio-group>
				</el-form-item>
				<div v-if="refundOrderForm.isRefund">
					<el-form-item label="退款方式">
						<el-radio-group v-model="refundOrderForm.refundType">
							<el-radio label="WECHAT_REFUND">微信方式</el-radio>
							<el-radio label="ALI_REFUND">支付宝方式</el-radio>
							<el-radio label="OTHER_REFUND">其他</el-radio>
						</el-radio-group>
					</el-form-item>

					<el-form-item label="上传凭证">
						<el-upload :action="uploadModel.uploadUrl" list-type="picture-card" :on-preview="uploadModel.onPreview" :on-remove="uploadModel.onRemove" :on-success="uploadModel.onUploadSuccess" :file-list="uploadModel.fileList" :on-progress="uploadModel.progress" :on-error="uploadModel.error" :before-upload="uploadModel.onBefore">
							<i class="el-icon-plus"></i>
						</el-upload>
					</el-form-item>
					<!-- <div style="    color: #fa5555;    font-size: 12px;" v-if="uploadModel.fileList.length === 0">请上传一张以上的图片</div> -->
				</div>
				<el-form-item label="备注">
					<el-input type="text" v-model="refundOrderForm.remark" />
				</el-form-item>

			</el-form>

			<span slot="footer" class="dialog-footer">
              <el-button @click="refundModel=false">取消</el-button>
              <el-button type="primary" @click="refund()">确定</el-button>
            </span>
		</el-dialog>

		<el-dialog :visible.sync="imageDialogModel.show">
			<img width="100%" :src="imageDialogModel.imageUrl" alt="">
		</el-dialog>

	</div>
</template>

<script>
	import * as Api from "@/api/Api.js";
	import * as RoundApi from "@/api/RoundApi.js";
	import * as Config from "@/api/Config.js";
	export default {
		data() {
			return {
				isrefund: false,
				orderId: "",
				orderDatil: [],
				pageId: "0",
				imageDialogModel: {
					show: false,
					imageUrl: ""
				},

				refundOrder: {},

				uploadModel: {
					uploadUrl: "",
					fileList: [],
					onRemove: (file, fileList) => {
						// if (this.loadding) {
						//   this.$message("请等待上传成功再操作");
						//   return;
						// }
						this.uploadModel.fileList = fileList;
					},

					onBefore: () => {
						if(this.loadding) {
							return false;
						}
					},
					onPreview: file => {
						this.imageDialogModel.imageUrl = file.url;
						this.imageDialogModel.show = true;
					},

					onUploadSuccess: (response, file, fileList) => {
						console.log("上传成功");
						let dt = {
							name: "1.png",
							url: response.data.filename
						};
						this.uploadModel.fileList.push(dt);
						this.loadding = false;
					},
					error: () => {
						this.loadding = false;
					},
					progress: () => {
						this.loadding = true;
					},
					doPreview: () => {}
				},

				refundModel: false,
				refundOrderForm: {
					orderId: "",
					refundOrder: {},
					remark: "",
					refundVoucher: "",
					refundType: "WECHAT_REFUND",
					isRefund: true
				},
				sendModel: "add",
				sendgoodsModel: false,
				orderTableData: [],
				pageIndex: 1,
				count: 0,
				form: {
					page: 10,
					pageSize: 0,
					orderstatus: ""
				},
				sendForm: {
					orderId: "",
					transName: "AJ",
					transNo: "",
					transMobile: ""
				},
				imageList: [],
				bigIcon: "",
				viewBig: false,
				expressList: [{
						value: "AJ",
						name: "安捷快递"
					},
					{
						value: "ANE",
						name: "安能物流"
					},
					{
						value: "AXD",
						name: "安信达快递"
					},
					{
						value: "BQXHM",
						name: "北青小红帽"
					},
					{
						value: "BFDF",
						name: "百福东方"
					},
					{
						value: "BTWL",
						name: "百世快运"
					},
					{
						value: "CCES",
						name: "CCES快递"
					},
					{
						value: "CITY100",
						name: "城市100"
					},
					{
						value: "COE",
						name: "COE东方快递"
					},
					{
						value: "CSCY",
						name: "长沙创一"
					},
					{
						value: "CDSTKY",
						name: "成都善途速运"
					},
					{
						value: "DBL",
						name: "德邦"
					},
					{
						value: "DDWL",
						name: "大道物流"
					},
					{
						value: "DSWL",
						name: "D速物流"
					},
					{
						value: "DTWL",
						name: "大田物流"
					},
					{
						value: "EMS",
						name: "EMS"
					},
					{
						value: "FAST",
						name: "快捷速递"
					},
					{
						value: "FEDEX",
						name: "FEDEX联邦(国内件）"
					},
					{
						value: "FEDEX_GJ",
						name: "FEDEX联邦(国际件）"
					},
					{
						value: "FKD",
						name: "飞康达"
					},
					{
						value: "GDEMS",
						name: "广东邮政"
					},
					{
						value: "GSD",
						name: "共速达"
					},
					{
						value: "GTO",
						name: "国通快递"
					},
					{
						value: "GTSD",
						name: "高铁速递"
					},
					{
						value: "HFWL",
						name: "汇丰物流"
					},
					{
						value: "HHTT",
						name: "天天快递"
					},
					{
						value: "HLWL",
						name: "恒路物流"
					},
					{
						value: "HOAU",
						name: "天地华宇"
					},
					{
						value: "hq568",
						name: "华强物流"
					},
					{
						value: "HTKY",
						name: "百世快递"
					},
					{
						value: "HXLWL",
						name: "华夏龙物流"
					},
					{
						value: "HYLSD",
						name: "好来运快递"
					},
					{
						value: "JGSD",
						name: "京广速递"
					},
					{
						value: "JIUYE",
						name: "九曳供应链"
					},
					{
						value: "JJKY",
						name: "佳吉快运"
					},
					{
						value: "JLDT",
						name: "嘉里物流"
					},
					{
						value: "JTKD",
						name: "捷特快递"
					},
					{
						value: "JXD",
						name: "急先达"
					},
					{
						value: "JYKD",
						name: "晋越快递"
					},
					{
						value: "JYM",
						name: "加运美"
					},
					{
						value: "JYWL",
						name: "佳怡物流"
					},
					{
						value: "KYWL",
						name: "跨越物流"
					},
					{
						value: "LB",
						name: "龙邦快递"
					},
					{
						value: "LHT",
						name: "联昊通速递"
					},
					{
						value: "MHKD",
						name: "民航快递"
					},
					{
						value: "MLWL",
						name: "明亮物流"
					},
					{
						value: "NEDA",
						name: "能达速递"
					},
					{
						value: "PADTF",
						name: "平安达腾飞快递"
					},
					{
						value: "QCKD",
						name: "全晨快递"
					},
					{
						value: "QFKD",
						name: "全峰快递"
					},
					{
						value: "QRT",
						name: "全日通快递"
					},
					{
						value: "RFD",
						name: "如风达"
					},
					{
						value: "SAD",
						name: "赛澳递"
					},
					{
						value: "SAWL",
						name: "圣安物流"
					},
					{
						value: "SBWL",
						name: "盛邦物流"
					},
					{
						value: "SDWL",
						name: "上大物流"
					},
					{
						value: "SF",
						name: "顺丰快递"
					},
					{
						value: "SFWL",
						name: "盛丰物流"
					},
					{
						value: "SHWL",
						name: "盛辉物流"
					},
					{
						value: 'SLKY',
						name: '顺俐快运'
					},
					{
						value: "ST",
						name: "速通物流"
					},
					{
						value: "STO",
						name: "申通快递"
					},
					{
						value: "STWL",
						name: "速腾快递"
					},
					{
						value: "SURE",
						name: "速尔快递"
					},
					{
						value: 'SXWL',
						name: "燊熙物流"
					},
					{
						value: 'YTWL',
						name: "一通物流"
					},
					{
						value: "TSSTO",
						name: "唐山申通"
					},
					{
						value: "UAPEX",
						name: "全一快递"
					},
					{
						value: "UC",
						name: "优速快递"
					},
					{
						value: "WJWL",
						name: "万家物流"
					},
					{
						value: "WXWL",
						name: "万象物流"
					},
					{
						value: "XBWL",
						name: "新邦物流"
					},
					{
						value: "XFEX",
						name: "信丰快递"
					},
					{
						value: "XYT",
						name: "希优特"
					},
					{
						value: "XJ",
						name: "新杰物流"
					},
					{
						value: "YADEX",
						name: "源安达快递"
					},
					{
						value: "YCWL",
						name: "远成物流"
					},
					{
						value: "YD",
						name: "韵达快递"
					},
					{
						value: "YDH",
						name: "义达国际物流"
					},
					{
						value: "YFEX",
						name: "越丰物流"
					},
					{
						value: "YFHEX",
						name: "原飞航物流"
					},
					{
						value: "YFSD",
						name: "亚风快递"
					},
					{
						value: "YTKD",
						name: "运通快递"
					},
					{
						value: "YTO",
						name: "圆通速递"
					},
					{
						value: "YXKD",
						name: "亿翔快递"
					},
					{
						value: "YZPY",
						name: "邮政平邮/小包"
					},
					{
						value: "ZENY",
						name: "增益快递"
					},
					{
						value: "ZHQKD",
						name: "汇强快递"
					},
					{
						value: "ZJS",
						name: "宅急送"
					},
					{
						value: "ZTE",
						name: "众通快递"
					},
					{
						value: "ZTKY",
						name: "中铁快运"
					},
					{
						value: "ZTO",
						name: "中通速递"
					},
					{
						value: "ZTWL",
						name: "中铁物流"
					},
					{
						value: "ZYWL",
						name: "中邮物流"
					},
					{
						value: "AMAZON",
						name: "亚马逊物流"
					},
					{
						value: "SUBIDA",
						name: "速必达物流"
					},
					{
						value: "RFEX",
						name: "瑞丰速递"
					},
					{
						value: "QUICK",
						name: "快客快递"
					},
					{
						value: "CJKD",
						name: "城际快递"
					},
					{
						value: "CNPEX",
						name: "CNPEX中邮快递"
					},
					{
						value: "HOTSCM",
						name: "鸿桥供应链"
					},
					{
						value: "HPTEX",
						name: "海派通物流公司"
					},
					{
						value: "AYCA",
						name: "澳邮专线"
					},
					{
						value: "PANEX",
						name: "泛捷快递"
					},
					{
						value: "PCA",
						name: "PCA Express"
					},
					{
						value: "UEQ",
						name: "UEQ Express"
					},
					{
						value: "AFT",
						name: "阿凡提物流"
					},
					{
						value: "AH",
						name: "安华物流"
					},
					{
						value: "AJ",
						name: "安捷物流"
					},
					{
						value: "AS",
						name: "安胜物流"
					},
					{
						value: "BJ",
						name: "奔骏物流"
					},
					{
						value: "BW",
						name: "保卫物流"
					},
					{
						value: "CC",
						name: "长城物流"
					},
					{
						value: "CH",
						name: "长航物流"
					},
					{
						value: "CJ",
						name: "诚捷物流"
					},
					{
						value: "CJ",
						name: "成捷物流"
					},
					{
						value: "CT",
						name: "长通物流"
					},
					{
						value: "CX",
						name: "承信物流"
					},
					{
						value: "DBY",
						name: "大本赢物流"
					},
					{
						value: "DY",
						name: "大元物流"
					},
					{
						value: "DY",
						name: "东越物流"
					},
					{
						value: "FD",
						name: "丰达物流"
					},
					{
						value: "FH",
						name: "富华物流"
					},
					{
						value: "FS",
						name: "飞送物流"
					},
					{
						value: "GJ",
						name: "广集物流"
					},
					{
						value: "GLCHX",
						name: "广龙昌（华信）"
					},
					{
						value: "GM",
						name: "广明物流"
					},
					{
						value: "GS",
						name: "广盛物流"
					},
					{
						value: "GY",
						name: "冠粤物流"
					},
					{
						value: "GY",
						name: "港岩物流"
					},
					{
						value: "GY",
						name: "广岩物流"
					},
					{
						value: "HD",
						name: "恒大物流"
					},
					{
						value: "HG",
						name: "惠国物流"
					},
					{
						value: "HJ",
						name: "豪杰物流"
					},
					{
						value: "HS",
						name: "黄石物流"
					},
					{
						value: "HT",
						name: "恒泰物流"
					},
					{
						value: "HT",
						name: "宏泰物流"
					},
					{
						value: "HW",
						name: "华威物流"
					},
					{
						value: "HY",
						name: "华阳物流"
					},
					{
						value: "JB",
						name: "捷豹物流"
					},
					{
						value: "JC",
						name: "疆驰物流"
					},
					{
						value: "JD",
						name: "嘉达物流"
					},
					{
						value: "JD",
						name: "佳达物流"
					},
					{
						value: "JHD",
						name: "吉宏达物流"
					},
					{
						value: "JM",
						name: "今明物流"
					},
					{
						value: "JP",
						name: "吉鹏物流"
					},
					{
						value: "JS",
						name: "金顺物流"
					},
					{
						value: "JS",
						name: "金顺物流"
					},
					{
						value: "JSCD",
						name: "金山车队物流"
					},
					{
						value: "JSD",
						name: "急速达物流"
					},
					{
						value: "JX",
						name: "剑翔物流"
					},
					{
						value: "JX",
						name: "劲翔物流"
					},
					{
						value: "LB",
						name: "猎豹物流"
					},
					{
						value: "LH",
						name: "联宏物流"
					},
					{
						value: "LS",
						name: "蓝色物流"
					},
					{
						value: "LT",
						name: "利通物流"
					},
					{
						value: "LT",
						name: "联通物流"
					},
					{
						value: "MH",
						name: "明浩物流"
					},
					{
						value: "MZJSH",
						name: "梅州金三和物流"
					},
					{
						value: "QJ",
						name: "全进物流"
					},
					{
						value: "QS",
						name: "邱氏（粤俊）物流"
					},
					{
						value: "RX",
						name: "日新物流"
					},
					{
						value: "SB",
						name: "三堡物流"
					},
					{
						value: "SF",
						name: "盛飞物流"
					},
					{
						value: "SJ",
						name: "岁佳物流"
					},
					{
						value: "SJ",
						name: "顺捷物流"
					},
					{
						value: "SM",
						name: "顺马物流"
					},
					{
						value: "SM",
						name: "顺马物流"
					},
					{
						value: "TF",
						name: "腾飞物流"
					},
					{
						value: "TR",
						name: "天润物流"
					},
					{
						value: "TX",
						name: "泰乡物流"
					},
					{
						value: "TY",
						name: "天佑物流"
					},
					{
						value: "WD",
						name: "文达物流"
					},
					{
						value: "WS",
						name: "万胜物流"
					},
					{
						value: "WY",
						name: "五洋物流"
					},
					{
						value: "XHD",
						name: "新华东物流"
					},
					{
						value: "XHJ",
						name: "新辉捷安达物流"
					},
					{
						value: "XJ",
						name: "详捷物流"
					},
					{
						value: "XX",
						name: "鑫鑫物流"
					},
					{
						value: "XY",
						name: "鑫燕物流"
					},
					{
						value: "YB",
						name: "义邦物流"
					},
					{
						value: "YD",
						name: "粤达物流"
					},
					{
						value: "YD",
						name: "远大物流"
					},
					{
						value: "YD",
						name: "粤达物流"
					},
					{
						value: "YJ",
						name: "云景物流"
					},
					{
						value: "YJ",
						name: "一举物流"
					},
					{
						value: "YS",
						name: "一顺物流"
					},
					{
						value: "YS",
						name: "豫商物流"
					},
					{
						value: "YS",
						name: "越胜物流"
					},
					{
						value: "YT",
						name: "一通物流"
					},
					{
						value: "ZE",
						name: "中俄物流"
					},
					{
						value: "ZJ",
						name: "正嘉物流"
					},
					{
						value: "ZJ",
						name: "正嘉物流"
					},
					{
						value: "ZS",
						name: "喆速物流"
					},
					{
						value: "ZS",
						name: "浙顺物流"
					},
					{
						value: "ZT",
						name: "正铁物流"
					}

				],
				shipList: []
			};
		},

		methods: {
			goDetil(orderId) {
				let model = {
					orderId: orderId
				};
				this.orderId = orderId;
				RoundApi.getDetil(this, model).then(res => {
					if(res.retCode) {
						console.log(res);

						this.orderDatil = res.data;
						if((this.orderDatil.refundOrder || "") != "") {
							this.isrefund = true;
						}
						if(
							res.data.orderStatus !== "ORDER_CANCEL_PAY" &&
							res.data.orderStatus != "ORDER_WAIT_SENDGOODS" &&
							res.data.orderStatus !== "ORDER_WAIT_PAY"
						) {
							this.getShipList(orderId);
						}

						this.pageId = "1";
					} else {
						this.$message("查询失败");
					}
				});
			},
			handleShipCode(row) {
				switch(row) {
					case "AJ":
						return "安捷快递";
					case "ANE":
						return "安能物流";
					case "AXD":
						return "安信达快递";
					case "BQXHM":
						return "北青小红帽";
					case "BFDF":
						return "百福东方";
					case "BTWL":
						return "百世快运";
					case "CCES":
						return "CCES快递";
					case "CITY100":
						return "城市100";
					case "COE":
						return "COE东方快递";
					case "CSCY":
						return "长沙创一";
					case "CDSTKY":
						return "成都善途速运";
					case "DBL":
						return "德邦";
					case "DSWL":
						return "D速物流";
					case "DTWL":
						return "大田物流";
					case "DDWL":
						return "大道物流"
					case "SXWL":
						return "燊熙物流"
					case "YTWL":
						return "一通物流"
					case "EMS":
						return "EMS";
					case "FAST":
						return "快捷速递";
					case "FEDEX":
						return "FEDEX联邦(国内件）";
					case "FEDEX_GJ":
						return "FEDEX联邦(国际件）";
					case "FKD":
						return "飞康达";
					case "GDEMS":
						return "广东邮政";
					case "GSD":
						return "共速达";
					case "GTO":
						return "国通快递";
					case "GTSD":
						return "高铁速递";
					case "HFWL":
						return "汇丰物流";
					case "HHTT":
						return "天天快递";
					case "HLWL":
						return "恒路物流";
					case "HOAU":
						return "天地华宇";
					case "hq568":
						return "华强物流";
					case "HTKY":
						return "百世快递";
					case "HXLWL":
						return "华夏龙物流";
					case "HYLSD":
						return "好来运快递";
					case "JGSD":
						return "京广速递";
					case "JIUYE":
						return "九曳供应链";
					case "JJKY":
						return "佳吉快运";
					case "JLDT":
						return "嘉里物流";
					case "JTKD":
						return "捷特快递";
					case "JXD":
						return "急先达";
					case "JYKD":
						return "晋越快递";
					case "JYM":
						return "加运美";
					case "JYWL":
						return "佳怡物流";
					case "KYWL":
						return "跨越物流";
					case "LB":
						return "龙邦快递";
					case "LHT":
						return "联昊通速递";
					case "MHKD":
						return "民航快递";
					case "MLWL":
						return "明亮物流";
					case "NEDA":
						return "能达速递";
					case "PADTF":
						return "平安达腾飞快递";
					case "QCKD":
						return "全晨快递";
					case "QFKD":
						return "全峰快递";
					case "QRT":
						return "全日通快递";
					case "RFD":
						return "如风达";
					case "SAD":
						return "赛澳递";
					case "SAWL":
						return "圣安物流";
					case "SBWL":
						return "盛邦物流";
					case "SDWL":
						return "上大物流";
					case "SF":
						return "顺丰快递";
					case "SFWL":
						return "盛丰物流";
					case "SHWL":
						return "盛辉物流";
					case "SLKY":
						return "顺俐快运";
					case "ST":
						return "速通物流";
					case "STO":
						return "申通快递";
					case "STWL":
						return "速腾快递";
					case "SURE":
						return "速尔快递";
					case "TSSTO":
						return "唐山申通";
					case "UAPEX":
						return "全一快递";
					case "UC":
						return "优速快递";
					case "WJWL":
						return "万家物流";
					case "WXWL":
						return "万象物流";
					case "XBWL":
						return "新邦物流";
					case "XFEX":
						return "信丰快递";
					case "XYT":
						return "希优特";
					case "XJ":
						return "新杰物流";
					case "YADEX":
						return "源安达快递";
					case "YCWL":
						return "远成物流";
					case "YD":
						return "韵达快递";
					case "YDH":
						return "义达国际物流";
					case "YFEX":
						return "越丰物流";
					case "YFHEX":
						return "原飞航物流";
					case "YFSD":
						return "亚风快递";
					case "YTKD":
						return "运通快递";
					case "YTO":
						return "圆通速递";
					case "YXKD":
						return "亿翔快递";
					case "YZPY":
						return "邮政平邮/小包";
					case "ZENY":
						return "增益快递";
					case "ZHQKD":
						return "汇强快递";
					case "ZJS":
						return "宅急送";
					case "ZTE":
						return "众通快递";
					case "ZTKY":
						return "中铁快运";
					case "ZTO":
						return "中通速递";
					case "ZTWL":
						return "中铁物流";
					case "ZYWL":
						return "中邮物流";
					case "AMAZON":
						return "亚马逊物流";
					case "SUBIDA":
						return "速必达物流";
					case "RFEX":
						return "瑞丰速递";
					case "QUICK":
						return "快客快递";
					case "CJKD":
						return "城际快递";
					case "CNPEX":
						return "CNPEX中邮快递";
					case "HOTSCM":
						return "鸿桥供应链";
					case "HPTEX":
						return "海派通物流公司";
					case "AYCA":
						return "澳邮专线";
					case "PANEX":
						return "泛捷快递";
					case "PCA":
						return "PCA Express";
					case "UEQ":
						return "UEQ Express";
					case "AFT":
						return "阿凡提物流";
					case "AH":
						return "安华物流";
					case "AJ":
						return "安捷物流";
					case "AS":
						return "安胜物流";
					case "BJ":
						return "奔骏物流";
					case "BW":
						return "保卫物流";
					case "CC":
						return "长城物流";
					case "CH":
						return "长航物流";
					case "CJ":
						return "诚捷物流";
					case "CJ":
						return "成捷物流";
					case "CT":
						return "长通物流";
					case "CX":
						return "承信物流";
					case "DBY":
						return "大本赢物流";
					case "DY":
						return "大元物流";
					case "DY":
						return "东越物流";
					case "FD":
						return "丰达物流";
					case "FH":
						return "富华物流";
					case "FS":
						return "飞送物流";
					case "GJ":
						return "广集物流";
					case "GLCHX":
						return "广龙昌（华信）";
					case "GM":
						return "广明物流";
					case "GS":
						return "广盛物流";
					case "GY":
						return "冠粤物流";
					case "GY":
						return "港岩物流";
					case "GY":
						return "广岩物流";
					case "HD":
						return "恒大物流";
					case "HG":
						return "惠国物流";
					case "HJ":
						return "豪杰物流";
					case "HS":
						return "黄石物流";
					case "HT":
						return "恒泰物流";
					case "HT":
						return "宏泰物流";
					case "HW":
						return "华威物流";
					case "HY":
						return "华阳物流";
					case "JB":
						return "捷豹物流";
					case "JC":
						return "疆驰物流";
					case "JD":
						return "嘉达物流";
					case "JD":
						return "佳达物流";
					case "JHD":
						return "吉宏达物流";
					case "JM":
						return "今明物流";
					case "JP":
						return "吉鹏物流";
					case "JS":
						return "金顺物流";
					case "JS":
						return "金顺物流";
					case "JSCD":
						return "金山车队物流";
					case "JSD":
						return "急速达物流";
					case "JX":
						return "剑翔物流";
					case "JX":
						return "劲翔物流";
					case "LB":
						return "猎豹物流";
					case "LH":
						return "联宏物流";
					case "LS":
						return "蓝色物流";
					case "LT":
						return "利通物流";
					case "LT":
						return "联通物流";
					case "MH":
						return "明浩物流";
					case "MZJSH":
						return "梅州金三和物流";
					case "QJ":
						return "全进物流";
					case "QS":
						return "邱氏（粤俊）物流";
					case "RX":
						return "日新物流";
					case "SB":
						return "三堡物流";
					case "SF":
						return "盛飞物流";
					case "SJ":
						return "岁佳物流";
					case "SJ":
						return "顺捷物流";
					case "SM":
						return "顺马物流";
					case "SM":
						return "顺马物流";
					case "TF":
						return "腾飞物流";
					case "TR":
						return "天润物流";
					case "TX":
						return "泰乡物流";
					case "TY":
						return "天佑物流";
					case "WD":
						return "文达物流";
					case "WS":
						return "万胜物流";
					case "WY":
						return "五洋物流";
					case "XHD":
						return "新华东物流";
					case "XHJ":
						return "新辉捷安达物流";
					case "XJ":
						return "详捷物流";
					case "XX":
						return "鑫鑫物流";
					case "XY":
						return "鑫燕物流";
					case "YB":
						return "义邦物流";
					case "YD":
						return "粤达物流";
					case "YD":
						return "远大物流";
					case "YD":
						return "粤达物流";
					case "YJ":
						return "云景物流";
					case "YJ":
						return "一举物流";
					case "YS":
						return "一顺物流";
					case "YS":
						return "豫商物流";
					case "YS":
						return "越胜物流";
					case "YT":
						return "一通物流";
					case "ZE":
						return "中俄物流";
					case "ZJ":
						return "正嘉物流";
					case "ZJ":
						return "正嘉物流";
					case "ZS":
						return "喆速物流";
					case "ZS":
						return "浙顺物流";
					case "ZT":
						return "正铁物流";

				}
			},
			viewBigIcon(url) {
				this.bigIcon = url;
				this.viewBig = true;
			},

			expandOnchange(row, expandedRows) {
				console.log(row, expandedRows);
			},
			getShipList(orderId) {
				RoundApi.getShipList(this, {
					orderId: orderId
				}).then(res => {
					console.log("物流信息", res);

					if(res.retCode) {
						this.shipList = res.data;
						let traces = [];
						for(let i = this.shipList.traces.length; i > 0; i--) {
							traces.push(this.shipList.traces[i - 1]);
						}
						this.shipList.traces = traces;
					} else {
						this.$message("查询失败");
					}
				});
			},
			refund() {
				if(this.refundOrderForm.isRefund) {
					if(!this.uploadModel.fileList.length > 0) {
						this.$message("请上传一张以上的凭证");
						return;
					}
					let refundVoucher = [];
					this.uploadModel.fileList.forEach((item, index) => {
						refundVoucher.push(item.url);
					});
					let opt = {
						orderId: this.refundOrderForm.orderId,
						refundVoucher: refundVoucher,
						refundType: this.refundOrderForm.refundType,
						remark: this.refundOrderForm.remark
					};

					RoundApi.acceptRefund(this, opt).then(res => {
						if(res.retCode) {
							this.$message("处理成功");
							this.refundModel = !this.refundModel;
							this.getOrderList();
						} else {
							this.$message("处理失败");
						}
					});
				} else {
					let opt = {
						orderId: this.refundOrderForm.orderId,
						remark: this.refundOrderForm.remark
					};

					RoundApi.aconRefund(this, opt).then(res => {
						if(res.retCode) {
							this.$message("已拒绝退款");
							this.refundModel = !this.refundModel;
							this.getOrderList();
						} else {
							this.$message("拒绝退款失败");
						}
					});
				}
			},
			doRefund(row) {
				let opt = [];
				if(this.pageId == "0") {
					opt = row;
				} else {
					opt = this.orderDatil;
				}

				this.refundOrderForm.orderId = opt.orderId;
				this.refundOrderForm.refundOrder = opt.refundOrder;
				if(this.refundOrderForm.refundOrder.refundImg != "") {
					this.imageList = this.refundOrderForm.refundOrder.refundImg.split(",");
				}

				this.refundModel = !this.refundModel;
			},
			send() {
				if(this.sendForm.transNo == "") {
					this.$message("请填写单号");
					return;
				}

				if(this.sendForm.transMobile == "") {
					this.$message("请填写物流公司号码");
					return;
				}
				console.log(this.sendModel);

				if(this.sendModel === "add") {
					RoundApi.doSendgoods(this, this.sendForm).then(res => {
						if(res.retCode) {
							console.log("发货", res);
							this.sendgoodsModel = !this.sendgoodsModel;

							this.$message("发货成功");
							this.getOrderList();
						} else {
							this.$message("发货失败");
						}
					});
				} else {
					RoundApi.updateSendgoods(this, this.sendForm).then(res => {
						console.log(res);

						if(res.retCode) {
							console.log("修改物流信息", res);
							this.sendgoodsModel = !this.sendgoodsModel;

							this.$message("更改物流信息成功");
							this.getShipList(this.orderId);
						} else {
							this.$message("更改物流信息失败");
						}
					});
				}
			},
			doChangeShip(row) {
				this.sendForm.transName = this.shipList.shipper_code;
				this.sendForm.transNo = this.shipList.logistic_code;
				this.sendForm.transMobile = this.shipList.mobile;

				this.sendForm.orderId = row.orderId;
				this.sendgoodsModel = !this.sendgoodsModel;
				this.sendModel = "edit";
			},
			doSendgoods(row) {
				this.sendForm.orderId = row.orderId;
				this.sendgoodsModel = !this.sendgoodsModel;
				this.sendModel = "add";
				//   RoundApi.getOrderList(this,this.form).then(res => {
				//   if (res.retCode) {
				//     console.log("订单列表", res);
				//     this.orderTableData = res.data;
				//   }
				// });
			},
			handleOrderStatus(status) {
				switch(status) {
					case "ORDER_WAIT_PAY":
						return "等待支付";
					case "ORDER_INPAY":
						return "正在支付";
					case "ORDER_CANCEL_PAY":
						return "订单关闭";
					case "ORDER_WAIT_SENDGOODS":
						return "等待发货";
					case "ORDER_WAIT_RECVGOODS":
						return "等待收货";
					case "ORDER_WAIT_REVIEW":
						return "等待评论";
					case "ORDER_END_GOODS":
						return "订单完成";
				}

				//   ORDER_WAIT_PAY, //待支付订单
				//     ORDER_INPAY, //正在支付
				//     ORDER_CANCEL_PAY, //取消支付订单
				//     ORDER_WAIT_SENDGOODS, //待发货订单
				//     ORDER_WAIT_RECVGOODS, //待收货订单
				//     ORDER_WAIT_REVIEW, //等待评论
				//     ORDER_END_GOODS; //订单完成
			},
			handleOrderRefundStatus(row) {
				switch(row) {
					case "WITHOUT_REFUND":
						return "未申请";
					case "APPLY_REFUND":
						return "申请退款中";
					case "WAIT_REFUND":
						return "等待退款中";
					case "SUCCEED_REFUND":
						return "退款完成";
					case "FAIL_REFUND":
						return "拒绝退款";
					case "END_ORDER":
						return "已完成7天不可退款";
				}
			},
			handleCurrentChange(val) {
				console.log(val);
				this.pageIndex = val;
				this.getOrderList();
			},
			getOrderList() {
				//分页 2个参数
				let pageSize = 10; //每页显示多少条记录。
				let pageIndex = this.pageIndex - 1; //第几页.

				//limit 计算.
				// let begin = pageIndex;
				//这里替换上面的 用于分页。

				this.form.pageSize = pageSize;
				this.form.page = pageIndex;

				RoundApi.getOrderList(this, this.form).then(res => {
					if(res.retCode) {
						console.log("订单列表", res);
						this.orderTableData = res.data.goodsList;
						this.count = res.data.page.total;
					}
				});
			}
		},
		mounted() {
			this.uploadModel.uploadUrl = Config.g_upload_url;
			this.getOrderList();

			if(this.$route.query.orderId) {
				this.goDetil(this.$route.query.orderId);
			}
		}
	};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>